package com.iprojectmanager.views;
import com.iprojectmanager.entities.*;

import java.util.*;
/**
 * @author Alucard
 */
public class Utilities
{
    public static String getDocType()
    {
        return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" +
                "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
    }

    public static String getHead(String title)
    {
        return 
       "<HEAD>" +
		"<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />"+
		"<meta name=\"author\" content=\"Sistema para la Administración de Proyectos de Software\" />"+
		"<meta name=\"keywords\" content=\"sistema, administración, proyectos, software, aplicaciones, web, saps\" />"+
		"<TITLE> " + title + "</TITLE>" +
		"<style type=\"text/css\" media=\"all\">" +
		"	@import \"black.css\";" +
		"</style>" +
	"</HEAD>";
    }
    
    public static String getHead(String title,String style)
    {
        return 
       "<HEAD>" +
		"<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" />"+
		"<meta name=\"author\" content=\"Sistema para la Administración de Proyectos de Software\" />"+
		"<meta name=\"keywords\" content=\"sistema, administración, proyectos, software, aplicaciones, web, saps\" />"+
		"<TITLE> " + title + "</TITLE>" +
		"<style type=\"text/css\" media=\"all\">" +
		"	@import \"black.css\";" +
                    style +
		"</style>" +
	"</HEAD>";
    }
    
    public static String getMenu()
    {
       return
               "<div id=\"linkList\">"+
                        "<div id=\"linkList2\">"+
                                "<div id=\"lselect\">"+
                                        "<ul>"+
                                                "<li><a href=\"http://www.saps.com\" title=\"\">Home</a> &nbsp; </li>"+
                                                "<li><a href=\"http://www.saps.com/admin\" title=\"\">Administrador</a>"+
                                                "de <a href=\"http://www.saps.com/proy\" class=\"c\">Proyecto</a> &nbsp; </li>"+
                                                "<li><a href=\"http://www.saps.com/lider\" title=\"\">Lider</a>"+
                                                "de <a href=\"http://www.saps.com/proy\" class=\"c\">Proyecto</a> &nbsp; </li>"+
                                                "<li><a href=\"http://www.saps.com/user\" title=\"\">Integrante</a>"+
                                                "de <a href=\"http://www.saps.com/proy\" class=\"c\">Proyecto</a> &nbsp; </li>"+
                                                "<li><a href=\"http://www.saps.com/links\" title=\"\">Links</a> &nbsp; </li>"+
                                        "</ul>"+
                                "</div>"+
                        "</div>"+
                "</div>";
    }

    public static String getFooter()
    {
        return
               "<div id=\"footer\">"+
                    "<a href=\"http://www.ipn.mx/\" title=\"Instituto Politécnico Nacional\">IPN</a> &nbsp;"+
                    "<a href=\"http://www.escom.ipn.mx/\" title=\"Escuela Superior de Cómputo\">ESCOM</a> &nbsp;"+
                    "<a href=\"http://www.escom.ipn.mx/ulises/desweb/\" title=\"Desarrollo de aplicaciones para la Web I\">WEB I</a> &nbsp;"+
                    "<a href=\"http://validator.w3.org/\" title=\"The W3C Markup Validation Service\">W3C</a> &nbsp;"+
		"</div>";
    }
    
    public static String getIntro(String title,Usuario user)
    {
        return
        	"<div id=\"intro\">"+
                    "<div id=\"header\">"+
                        "<h1><span>IProjectManager</span></h1>"+
                    "</div>"+
                    "<div id=\"help\">"+
			"<h3><p class=\"p1\"><span>" + title + " <br> " + user.getNombre() + " " + user.getApellidoPaterno() + " " +
                                                     user.getApellidoMaterno()+ "</span></p></h3>"+
                    "</div>"+
                    "<div id=\"estado\">"+
                        "<h3><p class=\"p1\"><span> " + 
                            "<a href=\"UserControl\" title=\"Salir de Session\">Cerrar Session</a> &nbsp;"+
			"</span></p></h3>"+
                    "</div>"+
                "</div>";
    }
    
        public static String getIntro(String title)
    {
        return
        	"<div id=\"intro\">"+
                    "<div id=\"header\">"+
                        "<h1><span>IProjectManager</span></h1>"+
                    "</div>"+
                    "<div id=\"help\">"+
			"<h3><p class=\"p1\"><span>" + title + "</span></p></h3>"+
                    "</div>"+
                    "<div id=\"estado\">"+
                        "<h3><p class=\"p1\"><span> " + 
                            "<a href=\"UserControl\" title=\"Salir de Session\">Cerrar Session</a> &nbsp;"+
			"</span></p></h3>"+
                    "</div>"+
                "</div>";
    }
    
    public static String getFormFecha(String title, String value, String day, int month, String year)
    {
        return 
                "<h3><span>" + title + "</span></h3>" +
                "<p class=\"p1\"><span>" +
                        "<table>" +
                            "<tr>" +
				"<td>Día</td><td>Mes</td><td>Año</td>" +
                            "</tr>" +
                            "<tr>" +
				"<td><input type=\"text\" name=\"dia"+ value +"\" size=\"20\" value=\""+ day +"\"></td>" +
                                "<td>" +
                                    "<select name=\"mes"+ value +"\">" +
                                        "<option"+ ((month == 0)?" selected ":"") +" value=\"0\">Enero" +
					"<option"+ ((month == 1)?" selected ":"") +" value=\"1\">Febrero" +
                                        "<option"+ ((month == 2)?" selected ":"") +" value=\"2\">Marzo" +
                                        "<option"+ ((month == 3)?" selected ":"") +" value=\"3\">Abril" +
                                        "<option"+ ((month == 4)?" selected ":"") +" value=\"4\">Mayo" +
                                        "<option"+ ((month == 5)?" selected ":"") +" value=\"5\">Junio" +
                                        "<option"+ ((month == 6)?" selected ":"") +" value=\"6\">Julio" +
                                        "<option"+ ((month == 7)?" selected ":"") +" value=\"7\">Agosto" +
                                        "<option"+ ((month == 8)?" selected ":"") +" value=\"8\">Septiembre " +
                                        "<option"+ ((month == 9)?" selected ":"") +" value=\"9\">Octubre" +
                                        "<option"+ ((month == 10)?" selected ":"") +" value=\"10\">Noviembre" +
                                        "<option"+ ((month == 11)?" selected ":"") +" value=\"11\">Diciembre" +
                                    "</select>" +
				"</td>" +
                                "<td><input type=\"text\" name=\"year"+ value +"\" size=\"20\" value=\""+ year +"\"></td>" +
                              "</tr>" +
			"</table>" +
                    "</span></p>";
    }
    
    public static int[] getDiff(Date dold, Date dn)
    {
        Calendar old = new GregorianCalendar(dold.getYear()+1900,dold.getMonth(),dold.getDate());
        Calendar n = new GregorianCalendar(dn.getYear()+1900,dn.getMonth(),dn.getDate());
        int[] diff = new int[3];
        int year=0;
	int month = 0;
	int day = 0;
	
            if(old.get(Calendar.YEAR) > n.get(Calendar.YEAR))
            {
                year = (old.get(Calendar.YEAR) - n.get(Calendar.YEAR))*-1;
            }
            else
            {
                year = - old.get(Calendar.YEAR) + n.get(Calendar.YEAR);
            }
			
            if(old.get(Calendar.MONTH) > n.get(Calendar.MONTH))
            {
                month = (old.get(Calendar.MONTH) - n.get(Calendar.MONTH))*-1;
            }
            else
            {
                month = - old.get(Calendar.MONTH) + n.get(Calendar.MONTH);
            }
			
            if(old.get(Calendar.DATE) > n.get(Calendar.DATE))
            {
                day = (old.get(Calendar.DATE) - n.get(Calendar.DATE))*-1;
            }
            else
            {
                day = - old.get(Calendar.DATE) + n.get(Calendar.DATE);
            }
            diff[0] = day;
            diff[1] = month;
            diff[2] = year;
        return diff;
    }
}
